package com.project.webpage.controller;


import com.github.pagehelper.PageInfo;
import com.project.webpage.aop.TagLog;
import com.project.webpage.dto.SearchByRqParam;
import com.project.webpage.dto.ShiftsOntimeDailyParam;
import com.project.webpage.dto.ShiftsOntimeMonthlyParam;
import com.project.webpage.dto.ShiftsOntimeParam;
import com.project.webpage.service.ShiftsOntimeService;
import com.project.webpage.util.RestResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/webpage/shiftsontime/")
public class ShiftsOntimeController extends BaseController {

    @Resource
    ShiftsOntimeService shiftsOntimeService;

    /**
     * 按日列表查询
     */
    @PostMapping("daily/page")
    @TagLog(operation = 0, content = "查询起讫站发车准点率按日列表")
    public RestResult page(@RequestBody ShiftsOntimeParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(shiftsOntimeService.getListForPage(param)));
    }

    /**
     * 导出按日列表
     */
    @PostMapping("daily/output")
    @TagLog(operation = 5, content = "导出起讫站发车准点率按日列表")
    public RestResult output(@RequestBody ShiftsOntimeParam param) {
        this.getPage(false, param);
        return RestResult.ok(shiftsOntimeService.getListForPage(param));
    }

    /**
     * 指定线路历史数据列表查询
     */
    @PostMapping("daily/jgxlid/page")
    @TagLog(operation = 0, content = "查询起讫站发车准点率指定线路历史数据列表")
    public RestResult pageByJgxlid(@RequestBody ShiftsOntimeDailyParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(shiftsOntimeService.getDailyListForPage(param)));
    }

    /**
     * 导出指定线路历史数据列表
     */
    @PostMapping("daily/jgxlid/output")
    @TagLog(operation = 5, content = "导出起讫站发车准点率指定线路历史数据列表")
    public RestResult outputByJgxlid(@RequestBody ShiftsOntimeDailyParam param) {
        this.getPage(false, param);
        return RestResult.ok(shiftsOntimeService.getDailyListForPage(param));
    }

    /**
     * 按月列表查询
     */
    @PostMapping("monthly/page")
    @TagLog(operation = 0, content = "查询起讫站发车准点率按月列表")
    public RestResult monthlyPage(@RequestBody ShiftsOntimeMonthlyParam param) {
        this.getPage(true, param);
        return RestResult.ok(new PageInfo<>(shiftsOntimeService.getMonthlyListForPage(param)));
    }

    /**
     * 导出按月列表
     */
    @PostMapping("monthly/output")
    @TagLog(operation = 5, content = "导出起讫站发车准点率按月列表")
    public RestResult monthlyOutput(@RequestBody ShiftsOntimeMonthlyParam param) {
        this.getPage(false, param);
        return RestResult.ok(shiftsOntimeService.getMonthlyListForPage(param));
    }

    /**
     * 按日详细列表查询
     */
    @PostMapping("daily/detail")
    @TagLog(operation = 0, content = "查询起讫站发车准点率按日详细列表")
    public RestResult detailPage(@RequestBody SearchByRqParam param) {
        this.getPage(false, param);
        return RestResult.ok(shiftsOntimeService.getDetail(param));
    }
}
